import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '@/views/layout.vue'
import detail from '@/views/article-detail.vue'
import article from '@/views/article.vue'
import collect from '@/views/collect.vue'
import like from '@/views/like.vue'
import user from '@/views/user.vue'

Vue.use(VueRouter)

const router = new VueRouter({
  // 都是代表是规则
  routes: [
    {
      name: 'layout',
      path: '/',
      component: layout,
      redirect: '/article',
      children: [
        { name: 'article', path: 'article', component: article },
        { name: 'collect', path: 'collect', component: collect },
        { name: 'like', path: 'like', component: like },
        { name: 'user', path: 'user', component: user }
      ]
    },
    // 访问detail这个页面必须携带一个参数叫id，不然无法访问
    { name: 'detail', path: '/detail/:id', component: detail }
  ]
})

export default router
